package com.ds.infrastructure.hyperspace.console.service.impl;

import com.ds.infrastructure.hyperspace.console.dao.dao.TbMethodLockDao;
import com.ds.infrastructure.hyperspace.console.entity.page.TbPageWhere;
import com.ds.infrastructure.hyperspace.console.entity.table.TbMethodLock;
import com.ds.infrastructure.hyperspace.console.entity.where.TbCustomWhere;
import com.ds.infrastructure.hyperspace.console.service.inf.IMethodLockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: yaozhendong
 * @create: 2019-10-16 15:22
 **/

@Service
public class MethodLockService implements IMethodLockService {
    @Autowired
    TbMethodLockDao tbMethodLockDao;

    @Override
    public int save(TbMethodLock record) {
        return tbMethodLockDao.insertSelective(record);
    }

    @Override
    public int update(TbMethodLock record) {
        return tbMethodLockDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public TbMethodLock get(Long id) {
        return tbMethodLockDao.selectByPrimaryKey(id);
    }

    @Override
    public int delete(Long id) {
        return tbMethodLockDao.deleteByPrimaryKey(id);
    }

    @Override
    public List<TbMethodLock> getList(TbMethodLock where, TbCustomWhere customWhere, TbPageWhere pageWhere) {
        return tbMethodLockDao.selectListForPage(where, customWhere, pageWhere);
    }

    @Override
    public int getTotal(TbMethodLock where, TbCustomWhere customWhere) {
        return tbMethodLockDao.selectListForPageCount(where, customWhere);
    }

    @Override
    public TbMethodLock selectOne(TbMethodLock where, TbCustomWhere customWhere) {
        List<TbMethodLock> itemList = tbMethodLockDao.selectListForPage(where, customWhere, TbPageWhere.newPage4OnlyOne());
        return itemList.stream().findFirst().orElseGet(() -> null);
    }
}
